/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ui.gui.table.model;

import javax.swing.table.AbstractTableModel;
import model.Customer;

/**
 *
 * @author Martin Mohr Pedersen
 */
public class CustomerTableModel extends AbstractTableModel {

    public static final int COL_NAME = 0;
    public static final int COL_PHONE = 1;
    public static final int COL_ADDRESS = 2;
    public static final int COL_ZIP = 3;

    private String[] colNames = {"Navn", "Telefonnr", "Adresse", "Postnr"};
    private Class[] colTypes = {java.lang.String.class, java.lang.Integer.class,
        java.lang.String.class, java.lang.Integer.class};

    public CustomerTableModel() {
        super();
    }

    @Override
    public int getRowCount() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public int getColumnCount() {
        return colNames.length;
    }

    @Override
    public String getColumnName(int index) {
        return colNames[index];
    }

    @Override
    public Class getColumnClass(int index) {
        return colTypes[index];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Customer customer = getCustomerAtIndex(rowIndex);

        switch (columnIndex) {
            case COL_NAME:
                return customer.getName();
            case COL_PHONE:
                return customer.getPhone();
            case COL_ADDRESS:
                return customer.getAddress();
            case COL_ZIP:
                return customer.getZipCode();
            default:
                return null;
        }
    }

    public Customer getCustomerAtIndex(int index) {
        if(index == -1){
            return null;
        }
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
